package OfferAliBaBa.b_23年数马笔试;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main3 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str = reader.readLine();
        String pattern = reader.readLine();
        System.out.println(fun1(str,pattern));

    }

    public static boolean fun1(String str, String pattern) {
        if (!pattern.contains("*")) {
            if (str.length() != pattern.length()) {
                return false;
            }
            char[] strArray = str.toCharArray();
            char[] patternArray = pattern.toCharArray();
            for (int i = 0; i < strArray.length; i++) {
                if ((strArray[i] ^ patternArray[i]) != 0 && patternArray[i] != '.') {
                    return false;
                }
            }
            return true;
        } else if (pattern.contains(".*")) {
            return true;
        }
        return false;
    }
}
